<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>投放明细</title>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<link rel="stylesheet" type="text/css" 
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<script type="text/javascript" src="<%=path%>/js/form.js"></script>
		<script type="text/javascript" src="<%=path%>/js/public.js"></script>
		<script type="text/javascript">
			$(function() {
				$(".closeButton").click(function(){
					var openId = $(this).parent().parent().parent().parent().attr("id");
					var closeId = openId.replace("open", "close");
					$("#"+openId).hide();
					$("#"+closeId).show();
				});
				$(".openButton").click(function(){
					var closeId = $(this).parent().parent().parent().parent().attr("id");
					var openId = closeId.replace("close", "open");
					$("#"+closeId).hide();
					$("#"+openId).show();
				});
				$(".initValue").blur(function(){
					var initValue = $(this).val();
					var id = $(this).attr("id").replace("open", "close");
					var reg = /^\d{1,3}$/;
					if(reg.test(initValue)){
						$("#"+id).text(initValue)
					}else{
						alert("必须为0~999以内数字！");
						$(this).val($("#"+id).text()); 
					}
					
				});
				$(".operation").mouseover(function(){
					$(this).css("color","#ffffff");
					$(this).css("background","#0078b6");
				});
				$(".operation").mouseout(function(){
					$(this).css("color","#0078b6");
					$(this).css("background","");
				});
				$("#arrangementSubmitButton").click(function(){
					if(confirm("排期修改后将需要重新设置费用信息，确认修改吗？")){
						var initValues = "";
						var count = 0;
						$(".initValue").each(function(){
							initValues += $(this).val() + ",";
							count++;
						});
						$("#mediumArrangement").val(initValues);
						
						formSubmit('arrangementForm', 'initArrangementInfo', 'editArrangementInfo.action', refrashCharge);
					}
				});
				$(".monthButton").click(function(){
					var openId = $(this).parent().parent().parent().parent().attr("id");
					$("#"+openId+" .initValue").each(function(){
						var i = $(this).val();
						i++;
						$(this).val(i);
						$("#"+$(this).attr("id").replace("open", "close")).text(i);
					});
				});
				$(".resetButton").click(function(){
					var id = $(this).parent().parent().parent().parent().attr("id");
					$("#"+id+" .initValue").each(function(){
						$(this).val($("#"+$(this).attr("id").replace("open", "init")).text());
						$("#"+$(this).attr("id").replace("open", "close")).text($(this).val());
					});
				});
			});
			
			function refrashCharge(html)
			{
			   alert('操作成功！');
			   loadPage('initCharge.action', {'proMedID':$("#proMedID").val()}, 'initCharge');
			}
		</script>
	</head> 

	<body>
		<input type="hidden" name="chkArrangement" id="chkArrangement" value="1"/>
		<br />
		<div id="list_div">
			<s:iterator value="initArrangements" status="status">
				<s:if test="#status.index == 0">
					<table id="m_${month }_open" class="table_list" style="margin: 0 auto;">
				</s:if>
				<s:else>
					<table id="m_${month }_open" class="table_list" style="margin: 0 auto; display: none;">
				</s:else>
					<tr>
						<th colspan="31" style="background: #f37c20;">
							${month }月
							<a class="closeButton operation" style="margin-right: 30px;">收起</a>
							<a class="operation resetButton" style="margin-right: 30px;">重置</a>
							<a class="monthButton operation" style="margin-right: 30px;">一个月</a> 
						</th>
					</tr>
					<tr>
						<s:iterator status="" value="dates">
							<s:if test="isShow == 2">
								<td style="width: 35px;${style }"></td>
							</s:if>
							<s:else>
								<td style="width: 35px; color: #000000;${style }">${day }</td>
							</s:else>
						</s:iterator>
					</tr>
					<tr>
						<s:iterator status="stu" value="dates">
							<s:if test="isShow == 2">
								<td style="${style }"></td>
							</s:if>
							<s:else>
								<td style="color: #000000;${style }"><s:property value="#stu.index+1"/></td>
							</s:else>
						</s:iterator>
					</tr>
					<tr>
						<s:iterator status="stu" value="dates"> 
							<s:if test="isShow == 0">
								<td style="${style }">
									<input id="m_${month }_open_<s:property value="#stu.index+1"/>" type="text" class="text initValue" style="text-align: center; width: 25px;" value="${initValue }" title="建议最大值为${suggesValue }"  />
								</td>
							</s:if>
							<s:elseif test="isShow == 1">
								<td style="${style }">-</td>
							</s:elseif>
							<s:else>
								<td style="${style }"></td>
							</s:else>
						</s:iterator>
					</tr>
				</table>
				<s:if test="#status.index == 0">
					<table id="m_${month }_close" class="table_list" style="margin: 0 auto; display: none;">
				</s:if>
				<s:else>
					<table id="m_${month }_close" class="table_list" style="margin: 0 auto;">
				</s:else>
				
					<tr>
						<th rowspan="2" style="width: 30px;background: #f37c20;">${month }<br />月</th>
						<s:iterator status="stu" value="dates">
							<s:if test="isShow == 2">
								<td style="width: 31px;"></td>
							</s:if>
							<s:else>
								<td style="width: 31px; color: #000000;">
									<s:property value="#stu.index+1"/>
								</td>
							</s:else>
						</s:iterator>
						<th rowspan="2" style="width: 91px; background: #f37c20;"> 
							<a class="openButton operation" style="float: none;">展开</a>
						</th>
					</tr>
					<tr>
						<s:iterator status="stu" value="dates"> 
							<s:if test="isShow == 0">
								<td id="m_${month }_close_<s:property value="#stu.index+1"/>">${initValue }</td>
							</s:if>
							<s:elseif test="isShow == 1">
								<td>-</td>
							</s:elseif>
							<s:else>
								<td></td>
							</s:else>
						</s:iterator>
					</tr>
				</table>
				<br />
				<table style="display: none;">
					<tr>
						<s:iterator status="stu" value="dates"> 
							<s:if test="isShow == 0">
								<td id="m_${month }_init_<s:property value="#stu.index+1"/>" >${initValue }</td>
							</s:if>
							
						</s:iterator>
					</tr>
				</table>
			</s:iterator>
		</div>
		<form id="arrangementForm" method="post">
			<div style="padding: 8px 0 0 150px;" align="center">
				<input id="arrangementSubmitButton" type="button" class="btn-title" value="保存" />
			</div>
			<div style="height: 5px;" />
			<input id="mediumArrangement" name="projectMedium.mediumArrangement" type="hidden" />
			<input id="proMedID" name="projectMedium.proMedID" value="${projectMedium.proMedID }" type="hidden"/>
		</form>
	</body>
</html>
